#!/bin/bash

ProcessDir="/home/SpringBoot/NetSecurity_Data_Process"

SendDir="/home/SpringBoot/NetSecurity_Data_Send"

LogFile="/home/rduser/springStart/Start_log"

Start_Porcess() {
	if [[ $1 =~ 'NetSecurity_Data_Process.jar' ]]; then
		cd ${ProcessDir}
		sh start_prod.sh
		echo "`date "+%F %H:%M:%S"` $1" >> ${LogFile}
	else
		cd ${SendDir}/$2
		sh start_prod.sh
		echo "`date "+%F %H:%M:%S"` $1" >> ${LogFile}
	fi
}

check_pid() {
	Pid_num=`ps -ef | grep "$1" | grep -v "grep $1" | wc -l`
	if (( ${Pid_num} < 1 )); then
		Start_Porcess $1 $2
	fi
}

check_pid "NetSecurity_Data_FoShan.jar" "FoShan"

check_pid "NetSecurity_Data_GuangZhou.jar" "Guangzhou"

check_pid "NetSecurity_Data_LiWan.jar" "Liwan"

check_pid "NetSecurity_Data_Process.jar" "Process"